package com.shujia.day17.lambda1;

import java.util.ArrayList;

public class Operator4 {
    public static void main(String[] args) {
        ArrayList<Staff> staffs = new ArrayList<>();
        staffs.add(new Staff("易政", 18, 12000));
        staffs.add(new Staff("李国涛", 19, 20000));
        staffs.add(new Staff("刘俊杰", 13, 8000));
        staffs.add(new Staff("陆玉龙", 12, 6000));


        System.out.println(new Filter() {
            @Override
            public ArrayList<Staff> filter(ArrayList<Staff> staffs, int salary) {
                ArrayList<Staff> lessStaff = new ArrayList<>();
                for (Staff staff : staffs) {
                    if (staff.salary <= salary) {
                        lessStaff.add(staff);
                    }
                }
                return lessStaff;
            }
        }.filter(staffs, 8000));


    }
    static interface Filter{
        public ArrayList<Staff> filter(ArrayList<Staff> staffs, int salary);
    }

}
